package com.yao.system.websocket.util;

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.GZIPOutputStream;

public class testts {

    public static void main(String[] args) {
        t2();
    }

    public void t1() {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String line = in.nextLine();
            String[] strings = line.split(",");
            List<String> list = Arrays.stream(strings).sorted((s1, s2) -> {
                return s1.compareTo(s2);
            }).collect(Collectors.toList());
            //sorted.forEach(v -> System.out.print(v + ","));
            int i = 0;
            for (String s : list) {
                if (i == list.size() - 1)
                    System.out.print(s);
                else
                    System.out.print(s + ",");
                i++;
            }
            System.out.println();
        }
    }

    public static void t2() {
        int[] nums = {0, 3, 7, 2, 5, 8, 4, 6, 0, 1};
        //Arrays.stream(nums).sorted();
        Arrays.sort(nums);

        int i = nums[0];
        List<Integer> list = new ArrayList<>();
        int s = 1;
        for (int x = 1; x <= nums.length; x++) {
            if (nums[x] - i > 1) {
                System.out.println(s);
                break;
            }
            i = nums[x];
            s++;
        }

    }

    public void t3(int[] nums) {
        int x = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != 0) {
                nums[x++] = nums[i];
            }
        }
        for (int i = x; i < nums.length; i++) {
            nums[i] = 0;
        }
    }


    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }

    class Solution {
        public TreeNode invertTree(TreeNode root) throws IOException {
            if (root == null) {
                return null;
            }

            TreeNode tmp = root.left;
            root.left = root.right;
            root.right = tmp;

            invertTree(root.left);
            invertTree(root.right);
            return root;
        }
    }

    abstract class tt{
        public tt(){
        boolean a =false;
        boolean b =true;
        }
    }

}
